
package com.kugou.game.sdk.api.common;

import org.json.JSONObject;

import com.kugou.framework.base.LogUtil;
import com.kugou.game.sdk.entity.AccountSecurityInfo;
import com.kugou.game.sdk.entity.UserCenterBannerInfo;

/**
 * 描述:用户信息实体
 *
 * @author jerryliu
 * @since 2015年12月8日 下午4:07:08
 */
public class User extends AccountSecurityInfo {
    private static final long serialVersionUID = 2970969657132511477L;

    private String openId = "";// 用户唯一标识

    private String userName = "";// 用户名

    private String nickName = "";// 昵称

    private String passwordInternal = "";// 密码

    private int userType;// 用户类型

    private String unixTime = "";// 时间戳

    private String token = "";// token

    private String kugouid = "";// id

    private String signature = "";// 个性签名

    private String sex = "";// 性别 (1：男，0：女)

    private String birthday = "";// 生日

    private String age = "";// 年龄

    private String province = "";// 省份

    private String city = "";// 城市

    private String headIconUrl = "";// 头像url

    private String trueName = "";// 真实姓名

    private int unreadmails = 0;// 未读邮件数量

    private String bindPhoneNum = "";// 绑定的手机号码

    private String kugouToken = "";// 酷狗token

    private long kugouTokenAppId;// appId，对应每个应用，在这里对应kugouToken

    private boolean hasGift = false;// 是否有礼包

    private boolean canGetGift = false;// 能否领取礼包

    private int kubiNum = -1;

    private UserCenterBannerInfo bannerInfo;

    /** 新邮件是否已经提醒过了--用于悬浮窗的红点提示 */
    private boolean unreadMailReminded = false;

    /** 游戏中心是否有红点提示--用于悬浮窗的红点提示 */
    private boolean gameCenterNeedRedPointRemind = false;

    /** 是否需要提醒该用户修改密码，默认不需要，自动注册用户才需要 */
    private boolean needRemindModifyPsd = false;

    /** 游客 */
    public static final int TEMP_USER = 0;

    /** 正式用户 */
    public static final int REGISTED_USER = 1;

    /**
     * 【酷狗平台正式账号】是否有设置登录密码，用于提示补填密码。比如 第三方账号登录生成的账号没有设置密码
     */
    private boolean setkugouPsd = true;

    public User() {
    }

    public User(String openId, String userName, String password, int userType) {
        super();
        this.openId = openId;
        this.userName = userName;
        this.passwordInternal = password;
        this.userType = userType;
    }

    public boolean isSetKugouPsd() {
        return setkugouPsd;
    }

    public void setSetKugouPsd(boolean setkugouPsd) {
        this.setkugouPsd = setkugouPsd;
    }

    public String getOpenId() {
        return openId;
    }

    public void setOpenId(String openId) {
        this.openId = openId;
    }

    // 改自getUserName
    public String getAccountName() {
        return userName;
    }

    // 改自setUserName
    public void setAccountName(String userName) {
        this.userName = userName;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public String getPassword() {
        return passwordInternal;
    }

    public void setPassword(String password) {
        this.passwordInternal = password;
    }

    public int getUserType() {
        return userType;
    }

    public void setUserType(int userType) {
        this.userType = userType;
    }

    public String getUnixTime() {
        return unixTime;
    }

    public String getToken() {
        return token;
    }

    public void setUnixTime(String unixTime) {
        this.unixTime = unixTime;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public String getKugouid() {
        return kugouid;
    }

    public void setKugouid(String kugouid) {
        this.kugouid = kugouid;
    }

    public String getSignature() {
        return signature;
    }

    public void setSignature(String signature) {
        this.signature = signature;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getProvince() {
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getHeadIconUrl() {
        return headIconUrl;
    }

    public void setHeadIconUrl(String headUrl) {
        this.headIconUrl = headUrl;
    }

    public String getTrueName() {
        return trueName;
    }

    public void setTrueName(String trueName) {
        this.trueName = trueName;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public int getUnreadmails() {
        return unreadmails;
    }

    public void setUnreadmails(int unreadmails) {
        this.unreadmails = unreadmails;
    }

    public boolean isRegistered() {
        return this.userType == REGISTED_USER;
    }

    public String getBindPhoneNum() {
        return bindPhoneNum;
    }

    public void setBindPhoneNum(String bindPhoneNum) {
        this.bindPhoneNum = bindPhoneNum;
    }

    public String getKugouToken() {
        return kugouToken;
    }

    public void setKugouToken(String kugouToken) {
        this.kugouToken = kugouToken;
    }

    public long getKugouTokenAppId() {
        return kugouTokenAppId;
    }

    public void setKugouTokenAppId(long kugouTokenAppId) {
        this.kugouTokenAppId = kugouTokenAppId;
    }

    public boolean isHasGift() {
        return hasGift;
    }

    public void setHasGift(boolean hasGift) {
        this.hasGift = hasGift;
    }

    public boolean isCanGetGift() {
        return canGetGift;
    }

    public void setCanGetGift(boolean canGetGift) {
        this.canGetGift = canGetGift;
    }

    public int getKubiNum() {
        // 如果服务端返回小于零，那么直接显示0
        if (kubiNum < 0) {
            kubiNum = 0;
        }
        return kubiNum;
    }

    public void setKubiNum(float kubiNum) {
        this.kubiNum = (int) kubiNum;
    }

    public boolean isUnreadMailReminded() {
        return unreadMailReminded;
    }

    public void setUnreadMailReminded(boolean unreadMailReminded) {
        this.unreadMailReminded = unreadMailReminded;
    }

    public boolean isNeedRemindModifyPsd() {
        return needRemindModifyPsd;
    }

    public void setNeedRemindModifyPsd(boolean needRemindModifyPsd) {
        this.needRemindModifyPsd = needRemindModifyPsd;
    }

    public boolean isGameCenterNeedRedPointRemind() {
        return gameCenterNeedRedPointRemind;
    }

    public void setGameCenterNeedRedPointRemind(boolean gameCenterNeedRedPointRemind) {
        this.gameCenterNeedRedPointRemind = gameCenterNeedRedPointRemind;
    }

    public UserCenterBannerInfo getBannerInfo() {
        return bannerInfo;
    }

    public void setBannerInfo(UserCenterBannerInfo bannerInfo) {
        this.bannerInfo = bannerInfo;
    }

    /**
     * 复制user传出去，过滤掉敏感数据(密码...)
     * 
     * @return
     */
    public User copySimpleUser() {
        User simpleUser = new User();
        simpleUser.openId = openId;
        simpleUser.userName = userName;
        simpleUser.nickName = nickName;
        simpleUser.token = token;
        simpleUser.unixTime = unixTime;
        simpleUser.userType = userType;
        simpleUser.sex = sex;
        simpleUser.age = age;
        simpleUser.birthday = birthday;
        simpleUser.province = province;
        simpleUser.city = city;
        simpleUser.bindPhoneNum = bindPhoneNum;
        simpleUser.headIconUrl = headIconUrl;
        return simpleUser;
    }

    @Override
    public String toString() {
        if (LogUtil.isDebug()) {
            try {
                JSONObject data = new JSONObject();
                data.put("openId", openId == null ? "" : openId);
                data.put("userName", userName == null ? "" : userName);
                data.put("nickName", nickName == null ? "" : nickName);
                data.put("password", passwordInternal == null ? "" : passwordInternal);
                data.put("userType", userType);
                data.put("unixTime", unixTime == null ? "" : unixTime);
                data.put("token", token == null ? "" : token);
                data.put("sex", sex == null ? "" : sex);
                data.put("age", age == null ? "" : age);
                data.put("birthday", birthday == null ? "" : birthday);
                data.put("province", province == null ? "" : province);
                data.put("city", city == null ? "" : city);
                data.put("bindPhoneNum", bindPhoneNum == null ? "" : bindPhoneNum);
                data.put("headUrl", headIconUrl == null ? "" : headIconUrl);
                return data.toString();
            } catch (Exception e) {
            }
        } else {
            StringBuilder userInfo = new StringBuilder();
            userInfo.append("openId: " + openId + "\n");
            userInfo.append("userName: " + userName + "\n");
            userInfo.append("nickName: " + nickName + "\n");
            userInfo.append("unixTime: " + unixTime + "\n");
            userInfo.append("token: " + token + "\n");
            userInfo.append("bindPhoneNum: " + bindPhoneNum + "\n");
            userInfo.append("userType: " + userType);
            return userInfo.toString();
        }
        return super.toString();
    }

}
